package com.bkgy.modular.tbdsjrawcheckc621.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.bkgy.modular.tbdsjrawcheckc621.entity.JTbDsjRawcheckC621;
import com.bkgy.modular.tbdsjrawcheckc621.entity.TbDsjRawcheckC621;
import com.bkgy.modular.tbdsjrawcheckc621.service.TbDsjRawcheckC621Service;
import com.bkgy.sys.common.entity.JCommon;
import com.bkgy.sys.common.entity.ResultData;
import com.bkgy.util.CodiUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;


/**
* 1720酸轧原料审核表控制器层
* @author  生成器生成
* @date 2022-10-18 10:08:09
*/
@RestController
@RequestMapping("/tbDsjRawcheckC621")
public class TbDsjRawcheckC621Controller {

	@Autowired
	private TbDsjRawcheckC621Service tbDsjRawcheckC621Service;
	
	/**
	 * 添加记录
	 * @param data userId 用户id
     * @param data sname 用户姓名
	 * */
	@CrossOrigin
	@RequestMapping(value={"/insert"}, method=RequestMethod.POST)
	@ResponseBody
	public ResultData insertDataTbDsjRawcheckC621(@RequestBody String data,@RequestHeader(value="loginToken") String loginToken){
		JCommon common = JSON.parseObject(loginToken,JCommon.class);
    	String sname = common.getSname();
    	Long userId = common.getUserId();
		return tbDsjRawcheckC621Service.insertDataTbDsjRawcheckC621(data,userId,CodiUtil.returnLm(sname));
	};
	
	/**
	 * 根据主键删除对象
	 * @param data json字符串
	 * */
	@CrossOrigin
	@RequestMapping(value={"/deleteOne"}, method=RequestMethod.POST)
	@ResponseBody
	public ResultData deleteDataTbDsjRawcheckC621One(@RequestBody String data){
		try{
    		JTbDsjRawcheckC621 jtbDsjRawcheckC621 = JSON.parseObject(data,JTbDsjRawcheckC621.class);
    		return tbDsjRawcheckC621Service.deleteDataTbDsjRawcheckC621One(jtbDsjRawcheckC621.getIndocno());
    	}catch(Exception e){
    		e.printStackTrace();
    		return ResultData.ResultDataFaultSelf("访问接口错误，错误信息为" + e.getMessage(), null); 
    	}
	};
	
	/**
     * 根据主键字符串删除多个对象
     * @param data json字符串
     */
    @CrossOrigin
    @RequestMapping(value = {"/deleteMany"}, method = RequestMethod.POST)
    @ResponseBody
    public ResultData deleteDataSysUserMany(@RequestBody String data) {
    	try{
    		JTbDsjRawcheckC621 jtbDsjRawcheckC621 = JSON.parseObject(data,JTbDsjRawcheckC621.class);
    		return tbDsjRawcheckC621Service.deleteDataTbDsjRawcheckC621Many(jtbDsjRawcheckC621.getStr_indocno());
    	}catch(Exception e){
    		e.printStackTrace();
    		return ResultData.ResultDataFaultSelf("访问接口错误，错误信息为" + e.getMessage(), null); 
    	}
    }
	
	/**
     * 修改记录
     * @param data json字符串
     * @param loginToken 请求头参数字符串对象
     */
    @CrossOrigin
	@RequestMapping(value={"/update"}, method=RequestMethod.POST)
	@ResponseBody
	public ResultData updateDataTbDsjRawcheckC621(@RequestBody String data,@RequestHeader(value="loginToken") String loginToken){
		JCommon common = JSON.parseObject(loginToken,JCommon.class);
    	String sname = common.getSname();
    	Long userId = common.getUserId();
		return tbDsjRawcheckC621Service.updateDataTbDsjRawcheckC621(data,userId,CodiUtil.returnLm(sname));
	};
	
	/**
     * 分页查看记录
     * @param data json字符串
     */
    @CrossOrigin
    @RequestMapping(value = {"/findByPage"}, method = RequestMethod.POST)
    @ResponseBody
    public ResultData findDataTbDsjRawcheckC621ByPage(@RequestBody String data) {
        return tbDsjRawcheckC621Service.findDataTbDsjRawcheckC621ByPage(data);
    }
    
    /**
     * 根据主键查询单条记录
     * @param data json字符串
     */
    @CrossOrigin
    @RequestMapping(value = {"/findByIndocno"}, method = RequestMethod.POST)
    @ResponseBody
    public ResultData findDataTbDsjRawcheckC621ByIndocno(@RequestBody String data) {
        return tbDsjRawcheckC621Service.findDataTbDsjRawcheckC621ByIndocno(data);
    }
	
	/**
	 * 查看记录
	 * @return list 对象集合返回
	 * */
	@CrossOrigin
	@RequestMapping(value={"/findAll"}, method=RequestMethod.POST)
	public List<TbDsjRawcheckC621> findDataTbDsjRawcheckC621(){
		return tbDsjRawcheckC621Service.findDataTbDsjRawcheckC621();
	};

	/**
	 * 使用热轧卷号HOT_COIL_ID到MongoDB的热轧blob查询曲线：
	 * 厚度hsm_fdh_thk_cold，宽度hsm_fdw_width_cold、凸度C40hsm_crown_c40、
	 * 楔形W40hsm_flatness_wedge40、终轧温度FDThsm_fdt_fdt、层冷温度CTChsm_ctc_ct_temp、
	 * 对称平坦度SYMhsm_flatness_symmetric_flatness、非对称平坦度ASYMhsm_flatness_asymmetric_flatness
	 * @param json
	 * @return
	 */
	@CrossOrigin
	@PostMapping("/findLineDataByVolumeNo")
	public ResultData findLineDataByVolumeNo(@RequestBody JSONObject json){
		return tbDsjRawcheckC621Service.findDataByHotVolumeNos(json);
	}

	/**
	 * 列表导出功能
	 * @param jsonObject
	 * @param response
	 */
	@PostMapping("/exportXlsx")
	public void export(@RequestBody JSONObject jsonObject, HttpServletResponse response) {
		tbDsjRawcheckC621Service.export(jsonObject,response);
	}
}
